package com.aaa.project;

public class Meth {
    /*数组的排序*/
    public static void sort(int[] arr){

        int len = arr.length;

        for (int i = 1; i < len; i++) {
            for(int j=0;j<len-i;j++){
                if(arr[j]>arr[j+1]){
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }

    }
    /*拼接*/
    public static String myToString(int[] arr) {
        String str = "[";
        for (int i = 0; i < arr.length; i++) {
            str += arr[i];
            if (i < arr.length - 1) {
                str += ",";
            } else {
                str += "]";
            }
        }
        return str;
    }
    /*查询位置*/
    public static int indexof(int[] arr,int a) {
        for (int i = 0; i < arr.length; i++) {
            if (a== arr[i]){
                return i;
            }
        }
        return - 1;
    }
    /*最大值.*/
    public static int Max(int[] arr) {
        int temp = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (temp < arr[i]) {
                temp = arr[i];
            }
        }
        return temp;
    }
    /*判断数组是否一致*/
    public static String yizhi(int [] arr , int [] arr1){
        if (arr.length != arr1.length) {
            return "不一致";
        }
        for (int i = 0; i < arr1.length; i++) {
            if (arr[i] != arr1[i]){
                return "不一致";
            }
        }
        return "一致";
    }
    }







